package com.xhsj.user.sms.process.service;

import com.xhsj.user.sms.process.entity.TbPurchaseProcessNode;
import com.xhsj.user.sms.process.mapper.TbPurchaseProcessNodeMapper;
import com.xhsj.user.sms.base.BaseService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 流程节点表 服务实现类
 * </p>
 *
 * @author suxiaolin
 * @since 2020-03-16
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class TbPurchaseProcessNodeService extends BaseService<TbPurchaseProcessNodeMapper, TbPurchaseProcessNode> {
    @Autowired
    private TbPurchaseProcessNodeMapper dao;


    /**
     * 获取第一个节点信息
     *
     * @author 苏小林
     * @date 2020/3/17 10:52
     */
    public TbPurchaseProcessNode getFirstNode(Integer dealWith,Object type) {
        QueryWrapper<TbPurchaseProcessNode> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", "0");
        queryWrapper.eq("deal_with", dealWith);
        queryWrapper.eq("type", type);
        queryWrapper.isNotNull("next_node_id");
        TbPurchaseProcessNode one = this.getOne(queryWrapper);
        return one;
    }

    public Map<String, Object> getNextNodeId(String nodeId, Integer status,String type) {
        return dao.getNextNodeId(nodeId, status,type);
    }

    //得到核检的下一个流程
    public List<Map<String, Object>> getZJNextNodeId(String nodeId, String type) {
        return dao.getZJNextNodeId(nodeId,type);
    }

    //合同获取第一个流程
    public List<Map<String,Object>> getContractFirstNode(Object type) {
        QueryWrapper<TbPurchaseProcessNode> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", "0");
        queryWrapper.eq("type", type);
        queryWrapper.isNotNull("next_node_id");
       return super.listMaps(queryWrapper);
    }
}
